package 力扣日常刷题.木22一月.第18天0130;

import java.util.Arrays;

/**
 * @author 帅小伙
 * @date 2022/1/30
 * @description
 */
public class Demo39数组使每位学生都有座位的最少移动次数 {


    public int minMovesToSeat(int[] seats, int[] students) {
        Arrays.sort(seats);
        Arrays.sort(students);
        int ans = 0;
        for (int i = 0; i < seats.length; i++) {
            ans += Math.abs(seats[i] - students[i]);
        }
        return ans;

    }

}
